function [img1, img2, img3, img4] = diff_JPEG2D(img, T)
    % DIFF_JPEG2D  calculate difference JPEG-2D array.
    if nargin < 2
        error('Wrong number of input arguments.');
    end
    [M,N] = size(img);
    img1 = threhold(img(1:M-1,1:N-1)-img(1:M-1,2:N), T); %horizontal
    img2 = threhold(img(1:M-1,1:N-1)-img(2:M,1:N-1), T); %vertical
    img3 = threhold(img(1:M-1,1:N-1)-img(2:M,2:N), T); %main diagonal
    img4 = threhold(img(2:M,1:N-1)-img(1:M-1,2:N), T); %minor diagonal
end
